home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #49 (Oct 89) / DMP Source / src / AZGlue.asm < prev    next >
Assembly Source File  |  1989-01-02  |  6KB  |  261 lines

  1. ;;
  2. ;; Glue for Printer Driver code resource headers using Aztec C.
  3. ;; Since the Aztec linker has no "-m" option like the MPW
  4. ;; linker, different headers for the various code resources
  5. ;; are obtained using conditional assembly.
  6. ;;
  7. ;; Earle R. Horton.  All rights reserved.
  8. ;;  Tuesday, December 13, 1988
  9. ;;
  10. ;; Some of the Glue routines contain data.  This is read-only!
  11. ;;
  12.  
  13.     ifd driver
  14.  
  15. JIODone     EQU $08fc
  16. myDrvrFlags EQU $1c00   ; Control, Stat, NeedGoodBye
  17. ;;
  18. ;; The header for the 'DRVR' resource.
  19. ;;
  20.     public  _myPrOpen   ; open routine
  21.     public  _myPrPrime  ; prime
  22.     public  _myPrControl    ; control
  23.     public  _myPrStatus ; status
  24.     public  _myPrClose  ; close
  25.  
  26.     public  _DriverEntry     ;; 'DRVR' starts here.
  27. _DriverEntry:
  28.     DC.W    myDrvrFlags ; control and status enable only
  29.     DC.W        0       ; doesn't need time
  30.     DC.W        0       ; no events
  31.     DC.W        0       ; no menu
  32.  
  33.  
  34.     DC.W    myPrOpenCall-_DriverEntry    ; Offsets to driver routines.
  35.     DC.W    myPrPrimeCall-_DriverEntry
  36.     DC.W    myPrControlCall-_DriverEntry
  37.     DC.W    myPrStatusCall-_DriverEntry
  38.     DC.W    myPrCloseCall-_DriverEntry
  39.  
  40.     DC.B    6,".Print"      ; Driver name as Pascal string
  41.     DC.W    0           ; Zero for word-align.
  42. dummyheader             ; Make it look like a procedure for
  43.     LINK    A6,#0       ; MacsBug
  44. myPrOpenCall
  45.     PEA _myPrOpen       ;; SP -> desired driver routine.
  46.     BRA.S   CallDriver  ;; Jump to interface to call real routine.
  47. myPrPrimeCall
  48.     PEA _myPrPrime      ;; Times 5.
  49.     BRA.S   CallDriver
  50. myPrControlCall
  51.     PEA _myPrControl
  52.     BRA.S   CallDriver
  53. myPrStatusCall
  54.     PEA _myPrStatus
  55.     BRA.S   CallDriver
  56. myPrCloseCall
  57.     PEA _myPrClose
  58. CallDriver
  59.     MOVE.L  A1,-(SP)        ;; Push pointer to device control entry.
  60.     MOVE.L  A0,-(SP)        ;; Push pointer to parameter block.
  61.     MOVEA.L 8(SP),A0        ;; Get routine address.
  62.     JSR (A0)                ;; Call driver routine.
  63.                             ;; Result is in D0.
  64.     MOVE.L  (SP)+,A0        ;; Restore registers.
  65.     MOVE.L  (SP)+,A1        ;; Note: C programs leave the stack alone.
  66.     ADDQ.W   #$4,A7         ;; Fix up stack pointer.
  67.     BTST    #$01,$0006(A0)  ;; Immediate call?
  68.     BNE.S   StdReturn       ;; Yes, regular return.
  69.     MOVE.L  JIODone,-(sp)   ;; No, return via IODone
  70. StdReturn
  71.     RTS
  72. label               ;; This is for MacsBug.
  73.     UNLK    A6
  74.     RTS
  75.     DC.B    'DMP-110 '
  76. ;
  77. ;   The rest of this module consists of read-only data.
  78. ;
  79. baud300     EQU 380
  80. baud600     EQU 189
  81. baud1200    EQU 94
  82. baud1800    EQU 62
  83. baud2400    EQU 46
  84. baud3600    EQU 30
  85. baud4800    EQU 22
  86. baud7200    EQU 14
  87. baud9600    EQU 10
  88. baud19200   EQU 4
  89. baud57600   EQU 0
  90.  
  91.  
  92.     public _AOutName,_BOutName,_BaudRates,_prhireslf
  93. ;
  94. ; Handy storage place for constant strings and data which can be copied
  95. ; by the Driver routines.
  96. ;
  97.  
  98. _AOutName
  99.     DC.B    5,".AOut"
  100. _BOutName
  101.     DC.B    5,".BOut"
  102.  
  103. _prhireslf
  104.     dc.b    3,26,27,"G"
  105.  
  106.     EVEN
  107.  
  108. _BaudRates
  109.     DC.W baud300
  110.     DC.W baud600
  111.     DC.W baud1200
  112.     DC.W baud1800
  113.     DC.W baud2400
  114.     DC.W baud3600
  115.     DC.W baud4800
  116.     DC.W baud7200
  117.     DC.W baud9600
  118.     DC.W baud19200
  119.     DC.W baud57600
  120.     endc
  121. ;;
  122. ;; The header for the Chooser Device Package.
  123. ;;
  124.     ifd pack
  125.  
  126.     public  _device
  127.     BRA.S   devicejump
  128. deviceID
  129.     DC.W    0
  130. Packname
  131.     DC.L    $5041434B   ; 'PACK'
  132. IDnumber
  133.     DC.W    $F000       ; -4096
  134. Version
  135.     DC.W    1
  136. Flags
  137.     DC.L    $0C00E000
  138. devicejump
  139.     JMP _device
  140.     endc
  141.  
  142. ;;
  143. ;; The header for the Job and Style Dialogs code.
  144. ;;
  145.     ifd dialog
  146.         public  _MyPrintDefault
  147.         public  _MyPrStlDialog
  148.         public  _MyPrJobDialog
  149.         public  _MyPrStlInit
  150.         public  _MyPrJobInit
  151.         public  _MyPrDlgMain
  152.         public  _MyPrValidate
  153.         public  _MyPrJobMerge
  154.         bra     _MyPrintDefault
  155.         bra     _MyPrStlDialog
  156.         bra     _MyPrJobDialog
  157.         bra     _MyPrStlInit
  158.         bra     _MyPrJobInit
  159.         bra     _MyPrDlgMain
  160.         bra     _MyPrValidate
  161.         bra     _MyPrJobMerge
  162. ;;
  163. ;; Routines to call Pascal procedures which are known by address
  164. ;; and not by name. (ProcPtr glue).
  165. ;;
  166.     public _CallDlgInit,_CallItemProc
  167. _CallDlgInit
  168. _CallItemProc
  169.         MOVE.L  (SP)+,A0    ; Pop return address.
  170.         MOVE.l  (SP)+,A1    ; Pop actual function address.
  171.         MOVE.L  A0,-(SP)    ; Push return address.
  172.         JMP (A1)        ; Call the Pascal Function
  173.         end
  174.     endc
  175. ;;
  176. ;; The header for the printing code.
  177. ;;
  178.     ifd print
  179.     public  _myPrOpenDoc
  180.     public  _myPrCloseDoc
  181.     public  _myPrOpenPage
  182.     public  _myPrClosePage
  183.     bra     _myPrOpenDoc
  184.     bra     _myPrCloseDoc
  185.     bra     _myPrOpenPage
  186.     bra     _myPrClosePage
  187.     public _NGetTrapAddress
  188.  
  189. _NGetTrapAddress
  190.      move.w     $0004(a7),d0
  191.      move.b     $0007(a7),d1
  192.      tst.b      d1
  193.      beq.s      ngettrapaddressret
  194.      dc.w       $a746           ; GetTrapAddress,SYS
  195.      bra.s      ngettrapaddressret
  196.      dc.w       $a346           ; GetTrapAddress,TOOL
  197. ngettrapaddressret
  198.      move.l     a0,d0
  199.      rts
  200.  
  201.  
  202. ;
  203. ;   The rest of this module consists of read-only data.
  204. ;
  205. baud300     EQU 380
  206. baud600     EQU 189
  207. baud1200    EQU 94
  208. baud1800    EQU 62
  209. baud2400    EQU 46
  210. baud3600    EQU 30
  211. baud4800    EQU 22
  212. baud7200    EQU 14
  213. baud9600    EQU 10
  214. baud19200   EQU 4
  215. baud57600   EQU 0
  216.  
  217.  
  218.     public _AOutName,_BOutName,_BaudRates
  219. ;
  220. ; Handy storage place for constant strings and data which can be copied
  221. ; by the Driver routines.
  222. ;
  223.  
  224. _AOutName
  225.     DC.B    5,".AOut"
  226. _BOutName
  227.     DC.B    5,".BOut"
  228.  
  229.     EVEN
  230.  
  231. _BaudRates
  232.     DC.W baud300
  233.     DC.W baud600
  234.     DC.W baud1200
  235.     DC.W baud1800
  236.     DC.W baud2400
  237.     DC.W baud3600
  238.     DC.W baud4800
  239.     DC.W baud7200
  240.     DC.W baud9600
  241.     DC.W baud19200
  242.     DC.W baud57600
  243.     endc
  244. ;
  245. ; This section used by pack.c and pdriver.c.
  246. ;
  247. PortBUse        EQU  $291
  248.     public _IsMPPOpen
  249. _IsMPPOpen     ;; Apparently left out of {clib}a.lib
  250.     moveq      #0,d1
  251.     move.b     PortBUse,d0
  252.     bmi.s      ismppopenreturn
  253.     andi.b     #$0f,d0
  254.     subq.b     #1,d0
  255.     bne.s      ismppopenreturn
  256.     moveq      #1,d1
  257. ismppopenreturn
  258.     move.b     d1,4(a7)
  259.     rts
  260.     end
  261.